<!DOCTYPE html>
<html>
<%
    response.setHeader("Cache-Control", "no-cache");
    response.setHeader("Pragma", "no-cache");
    response.setDateHeader("Expires", -1);
%>

<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://www.springframework.org/tags" prefix="s" %>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form" %>

<%@ page contentType="text/html;charset=UTF-8" language="java" %>


<head>
    <meta http-equiv="Pragma" content="no-cache">
    <meta http-equiv="expires" content="0">
    <title><s:message code="label.storeadministration"
                      text="Store administration"/>
    </title>


    <style type=text/css>

        body {
            padding-bottom: 40px;
            background-color: #eee;
        }

        .form-signin {

            max-width: 330px;
            padding: 100px 15px 15px 15px;
            margin: 0 auto;
        }

        .form-signin .form-signin-heading,
        .form-signin .checkbox {
            margin-bottom: 10px;
        }

        .form-signin .checkbox {
            font-weight: normal;
        }

        .form-signin .form-control {
            position: relative;
            height: auto;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            padding: 10px;
            font-size: 16px;
        }

        .form-signin .form-control:focus {
            z-index: 2;
        }

        .form-signin input[type="text"] {
            margin-bottom: -1px;
            border-bottom-right-radius: 0;
            border-bottom-left-radius: 0;
        }

        .form-signin input[type="password"] {
            margin-bottom: 10px;
            border-top-left-radius: 0;
            border-top-right-radius: 0;
        }

        .navbar-header .navbar-brand {
            color: #fff;
            font-size: 20px;
            text-transform: uppercase;
            font-weight: 200;
            letter-spacing: 2px;
        }

        #login-box h2 {
            padding: 0;
            margin: 0;
            color: #ebebeb;
            font: bold 36px "Calibri", Arial;
            border-bottom: 2px solid;
            padding-bottom: 0px;
        }


    </style>


    <link
            href="<c:url value="/resources/common/css/bootstrap.min.css" />"
            rel="stylesheet"/>


    <style type=text/css>
        .sm label {
            color: #EBEBEB;
            font-size: 16px;
        }

        .sm a {
            color: #EBEBEB;
            font-size: 16px;
        }


    </style>

    <script src="<c:url value="/resources/common/js/jquery-1.11.1.min.js" />"></script>
    <script src="<c:url value="/resources/common/js/bootstrap.min.js" />"></script>
    <script type="text/javascript" src="<c:url value="/resources/common/js/jquery-cookie.js"/>"></script>


    <script language="javascript">

        $(document).ready(function () {

            var username = $.cookie('admin_usernamecookie');
            if (username != null && username != '') {
                $('#j_username').val(username);
                $('#remember').attr('checked', true);
            }

            $("#formSubmitButton").click(function () {
                var hasError = false;

                if ($('#remember').prop('checked')== true) {
                    $.cookie('admin_usernamecookie', $('#j_username').val(), {expires: 1024, path: '/'});
                } else {
                    $.cookie('admin_usernamecookie',null, { expires: -1 });

                }
                if ($.trim($('#j_username').val()) == '') {
                    hasError = true;
                    alert("用户名不能为空");
                } else if ($.trim($('#j_password').val()) == '') {
                    hasError = true;
                    alert("密码不能空");
                }

                if (!hasError) {
                    $("#logonForm").submit();
                }

            });

            $("body").bind("keydown",function(e){
                var theEvent = e || window.event;
                var code = theEvent.keyCode || theEvent.which || theEvent.charCode;
                if (code == 13) {
                    //回车执行查询
                    $("#formSubmitButton").click();
                }
            });

        });
    </script>
</head>

<body>

<div class="container">
    <nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
        <div class="container-fluid">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle collapsed" data-toggle="collapse"
                        data-target="#sidebar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="#">后台管理</a>
            </div>
        </div>
        <!-- /.container-fluid -->
    </nav>


    <form method="post" id="logonForm" class="form-signin" role="form"
          action="<c:url value="/j_spring_security_check"/>">
        <c:if test="${not empty param.login_error}">
        <div class="alert alert-warning">
            用户名或密码错误！
        </div>
    </c:if>
        <h2 class="form-signin-heading"></h2>
        <input id="j_username" name="j_username" type="text" class="form-control" placeholder="用户名" required autofocus>
        <input id="j_password" name="j_password" type="password" class="form-control" placeholder="密码" required>

        <div class="checkbox">
            <label>
                <input id="remember" value="true"  name="_spring_security_remember_me" type="checkbox" > 记住我
            </label>
        </div>
        <button id="formSubmitButton" class="btn btn-lg btn-primary btn-block" type="button">登录</button>
    </form>

</div>
<!-- /container -->


</body>
</html>